<?php

namespace App\Modules\Apicrzs\Http\Controllers;

use App\Modules\Apicrzs\Services\System\AgreementService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class PublicController extends BaseApicrzsController
{


    public function getMallBasicConfig(Request $request): JsonResponse
    {
        $data['site_name'] = cnpscy_config('site_web_title');//网站名称
        $data['site_url'] = cnpscy_config('site_url');//网站地址
        $data['site_phone'] = cnpscy_config('site_phone');//网站电话
        $data['station_open'] = cnpscy_config('station_open')==1;//网站是否开启
        $data['wechat_auth_switch'] =cnpscy_config('routine_auth_type')==1;//微信登录开关
        $data['phone_auth_switch'] =  cnpscy_config('routine_auth_type') == 1;//手机号登录开关
        $data['page_foot'] = $this->getPageFootMenuList();
        $data['menu_config'] = $this->getMenuConfigLists();
        return $this->sendApiSuccess($data);
    }
    public function getPageFootMenuList(){
        $host = "https://grzq-base.oss-cn-qingdao.aliyuncs.com";
        $menuList=[
            'manage'=>[
                [
                    'currentIndex'=>'home',
                    'pagePath'=> "/pages/home/index",
                    'text'=> '首页',
                    'iconPath'=> $host.'/static/images/tabbar/index@2x.png',
                    'selectedIconPath'=>  $host.'/static/images/tabbar/index_click@2x.png',
                    'th'=>false
                ],
                [
                    'currentIndex'=>'tradeunion',
                    'pagePath'=> "/pages/tradeunion/tradeunion",
                    'text'=> '工会',
                    'iconPath'=> $host.'/static/images/tabbar/guorun@2x.png',
                    'selectedIconPath'=>  $host.'/static/images/tabbar/guorun_click@2x.png',
                    'th'=>false
                ],
                [
                    'currentIndex'=>'association',
                    'pagePath'=> "/pages/association/index",
                    'text'=> '我的社区',
                    'iconPath'=> $host.'/static/images/tabbar/shequn@2x.png',
                    'selectedIconPath'=>  $host.'/static/images/tabbar/shequn_click@2x.png',
                    'th'=>false
                ],
                [
                    'currentIndex'=>'user',
                    'pagePath'=> "/pages/user/index",
                    'text'=> '我的',
                    'iconPath'=> $host.'/static/images/tabbar/my@2x.png',
                    'selectedIconPath'=>  $host.'/static/images/tabbar/my_click@2x.png',
                    'th'=>false
                ],
            ],
            'buy'=>[

                [
                    'currentIndex'=>'home',
                    'pagePath'=> "/pages/home/index",
                    'text'=> '首页',
                    'iconPath'=> $host.'/static/images/tabbar/index@2x.png',
                    'selectedIconPath'=>  $host.'/static/images/tabbar/index_click@2x.png',
                    'th'=>false
                ],
                [
                    'currentIndex'=>'tradeunion',
                    'pagePath'=> "/pages/tradeunion/tradeunion",
                    'text'=> '工会',
                    'iconPath'=> $host.'/static/images/tabbar/guorun@2x.png',
                    'selectedIconPath'=>  $host.'/static/images/tabbar/guorun_click@2x.png',
                    'th'=>false
                ],

                [
                    'currentIndex'=>'dashui',
                    'pagePath'=> "/pages/index/home",
                    'text'=> '',
                    'iconPath'=> $host.'/static/images/tabbar/dashui@2x.png',
                    'selectedIconPath'=>  $host.'/static/images/tabbar/dashui_click@2x.png',
                    'th'=>false
                ],
                [
                    'currentIndex'=>'association',
                    'pagePath'=> "/pages/association/index",
                    'text'=> '我的社区',
                    'iconPath'=> $host.'/static/images/tabbar/shequn@2x.png',
                    'selectedIconPath'=>  $host.'/static/images/tabbar/shequn_click@2x.png',
                    'th'=>false
                ],
                [
                    'currentIndex'=>'user',
                    'pagePath'=> "/pages/user/index",
                    'text'=> '我的',
                    'iconPath'=> $host.'/static/images/tabbar/my@2x.png',
                    'selectedIconPath'=>  $host.'/static/images/tabbar/my_click@2x.png',
                    'th'=>false
                ]
            ],
            'intake'=>[
                [
                    'currentIndex'=>'home',
                    'pagePath'=> "/pages/home/index",
                    'text'=> '首页',
                    'iconPath'=> $host.'/static/images/tabbar/index@2x.png',
                    'selectedIconPath'=>  $host.'/static/images/tabbar/index_click@2x.png',
                    'th'=>false
                ],
                [
                    'currentIndex'=>'tradeunion',
                    'pagePath'=> "/pages/tradeunion/tradeunion",
                    'text'=> '工会',
                    'iconPath'=> $host.'/static/images/tabbar/guorun@2x.png',
                    'selectedIconPath'=>  $host.'/static/images/tabbar/guorun_click@2x.png',
                    'th'=>false
                ],
                [
                    'currentIndex'=>'dashui',
                    'pagePath'=> "/pages/index/home",
                    'text'=> '',
                    'iconPath'=> $host.'/static/images/tabbar/dashui@2x.png',
                    'selectedIconPath'=>  $host.'/static/images/tabbar/dashui_click@2x.png',
                    'th'=>false
                ],
                [
                    'currentIndex'=>'association',
                    'pagePath'=> "/pages/association/index",
                    'text'=> '我的社区',
                    'iconPath'=> $host.'/static/images/tabbar/shequn@2x.png',
                    'selectedIconPath'=>  $host.'/static/images/tabbar/shequn_click@2x.png',
                    'th'=>false
                ],
                [
                    'currentIndex'=>'intake_my',
                    'pagePath'=> "/pages/user/intake_my",
                    'text'=> '我的',
                    'iconPath'=> $host.'/static/images/tabbar/my@2x.png',
                    'selectedIconPath'=>  $host.'/static/images/tabbar/my_click@2x.png',
                    'th'=>false
                ]
            ],
        ];

        return $menuList;
    }
    public function getMenuConfigLists()
    {
        $host = "https://grzq-base.oss-cn-qingdao.aliyuncs.com/static";
        return [
            [
                'key'=>10,
                'is_login'=>false,
                'open' => true,
                'text'=>"扫码打水",
                'img'=>$host.'/images/home/scan@2x.png',
                'url'=>'/pages/intake/scan/index'
            ],
            [
                'key'=>11,
                'login'=>true,
                'open' => true,
                'text'=>"充值套餐",
                'img'=>$host.'/images/home/report@2x.png',
                'url'=>'/pages/intake/recharge/package'
            ],
            [
                'key'=>12,
                'is_login'=>false,
                'open' => true,
                'text'=>"水卡卡券",
                'img'=>$host.'/images/home/coupon@2x.png',
                'url'=>'/pages/intake/card/voucher'
            ],
            [
                'key'=>13,
                'is_login'=>false,
                'open' => true,
                'text'=>"流水记录",
                'img'=>$host.'/images/home/recharge@2x.png',
                'url'=>'/pages/intake/recharge/record'
            ],
            [

                'key'=>14,
                'is_login'=>false,
                'open' => false,
                'text'=>"分享有礼",
                'img'=>$host.'/images/home/share@2x.png',
                'url'=>'/pages/intake/share/index'
            ],
            [
                'key'=>15,
                'is_login'=>false,
                'open' => false,
                'text'=>"维保记录",
                'img'=>$host.'/images/home/maintenance@2x.png',
                'url'=>'/pages/intake/maintenance/index'
            ],
            [
                'key'=>16,
                'is_login'=>false,
                'open' => true,
                'text'=>"故障报修",
                'img'=>$host.'/images/home/fault@2x.png',
                'url'=>'/pages/intake/device/repair'
            ],
            [
                'key'=>17,
                'is_login'=>false,
                'open' => true,
                'text'=>"投诉反馈",
                'img'=>$host.'/images/home/complaint@2x.png',
                'url'=>'/pages/intake/feedback/index'
            ],
        ];
    }
    public function getAgreementType(Request $request,AgreementService $agreementServices): JsonResponse
    {
        $params = $request->all();
        $result = $agreementServices->getAgreementByType($params);
        return $this->sendApiSuccess($result, $agreementServices->getError());

    }
}
